Repository navigation
feat: add shell tab completion for bash, zsh, PowerShell and fish - #795
Open
ZheFeng7110 wants to merge 2 commits into
Open
ZheFeng7110 wants to merge 2 commits into
ZheFeng7110 wants to merge 2 commits into
Conversation
The fish adapter asked commandline for --tokens-expanded, a flag fish only gained in 4.0; the completion job's Ubuntu image ships fish 3.7, where the unknown flag left the word list empty and no candidate was produced. Ask for --tokenize (-o), which both lines accept and whose cut-at-cursor behaviour is the same. The Windows PowerShell job inherits MCPP from a Git Bash environment, so the value is /d/a/... rather than a native path and native Python resolved D:\d\a\... . Convert that spelling before resolving the binary.
Member
|
可以尝试把这个命令补全功能在 cmdline 这个库里优化好, 这样后面直接升级版本即可使用 (mcpp / xlings 和其他使用 cmdline的库 ) , 目前 cmdline里有个初步的实现可以研究一下 核心是 各个平台适配 兼容性 通用性 和 不改变 cmdline api 通用模块 能让使用 cmdline 库的 程序天然自动带有 completion 功能 (可以很简单使用一个 app.xxx(true) 控制是否启用), 具体可以参考下面相关链接 |
Member
Author
|
好的。 cmdline 目前的补全功能经过分析还存在问题,我先去优化 cmdline。 |
Member
Author
|
我调查了 mcpplibs/cmdline#8 的做法,它的实现与本分支的方式不同: mcpplibs/cmdline#8 是 而本分支的实现原理是 对于 mcpp 这种子命令较复杂,并且需要动态补全(比如 所以如果要通过 cmdline 实现 mcpp 的补全功能,我认为需要修改 cmdline 的补全实现方式:可以把 mcpplibs/cmdline#8 的方案撤回,改成后者的方案(用户按下 tab -> |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Tab completion now follows mcpp's CLI definitions for commands, nested subcommands, long and short options, and built-in option values. Bash, zsh, PowerShell and fish adapters use a read-only candidate query and their native filename completion, including attached file arguments.
mcpp self completion [shell]writes scripts under<mcpp-home>/config/shell/without initializing a toolchain or accessing the network. Normal sandbox initialization also installs the scripts. The standalone installer adds a guarded loading command to the detected shell's profile, respects custom configuration directories and quoting, and avoids duplicate entries.MCPP_NO_COMPLETIONandMCPP_NO_PATHindependently disable profile changes, and pinned older releases remain installable. English and Chinese installation instructions document manual activation.Closes #794.
Validation:
mcpp build --jobs 1succeeds.MCPP_JOBS=1and the release profile: 150 test targets pass.CI requires all four shells on Linux and checks native PowerShell completion on Windows.